15. Lesson Summary
Putting it All Into Perspective
When it comes to keeping track of data in your app, think about what will be done with that data, and what that data will look like as your user interfaces with your app. If you want your component to store mutable local data, consider using state
to hold this information. Many times, it is state
that will be used to manage controlled form elements in your components.
On the other hand, if some information isn't expected to change over time, and is generally designed to be "read-only" throughout your app, consider using props
instead. Both state
and props
will generally be in the form of an object, and changes in either will trigger a re-render of the component, but they each play very different roles in your app.
We covered a lot in this lesson, and you've made great progress - great work!
Lesson Challenge
Read these articles: Thinking in React,
Functional Components vs. Stateless Functional Components vs. Stateless Components,
Controlled Components
, Avoiding React SetState() Pitfalls, and How to NOT React: Common Anti-Patterns and Gotchas in React Answer the following questions and share your answers with your Study Group.
1) What is the difference between Stateless Functional Components and class components?
2) Describe the reasoning behind Controlled Components.
3) What is the correct way to modify state? Make sure to explain what role a child component like “Add User” can have in the app.